<?php

namespace App\Api\Logic;

use App\Api\Logic\Validate\UserAddressValidate;
use App\Exceptions\ValidationException;
use App\Helpers\ResponseEnum;

class UserAddressLogic extends BaseLogic
{
    /**
     * @return UserAddressValidate
     */
    private function getValidate():UserAddressValidate{
        return  new UserAddressValidate();
    }

    /**
     * 添加收获地址
     * @return void
     * @throws ValidationException
     */
    public function addAddress($params){
        $validate = $this->getValidate();
        if(!$validate->scene('addAddress')->check($params)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }

    }

    /**
     * @param array $params
     * @return void
     */
    public function delAddress($params)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('delAddress')->check($params)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }

    /**
     * 获取收获地址详情
     * @param array $params
     * @return void
     */
    public function getAddressInfo(array $params)
    {
        $validate = $this->getValidate();
        if(!$validate->scene('getAddressInfo')->check($params)){
            throw new ValidationException(ResponseEnum::HTTP_ERROR,$validate->getError());
        }
    }


}
